﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Wamm.ApplicationExceptions {
    public class RulesException : Exception {
        private static readonly Expression<Func<object, object>> ThisObject = x => x;

        public IList<RuleViolation> Errors { get; private set; }

        public RulesException(IList<RuleViolation> errors) {
            Errors = errors; 
        }

        public void ErrorForModel(string message) {
            Errors.Add(new RuleViolation { Property = ThisObject, Message = message });
        }
    }
}